home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 41
/
Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso
/
Aminet
/
comm
/
net
/
tf02.lha
/
TinyFugue
/
tf-lib
/
stack-q.tf
< prev
next >
Wrap
Text File
|
1995-08-12
|
686b
|
29 lines
;;;; Stack and queue macros.
;;;; Lets you keep stacks and queues of words. /pop and /dequeue give their
;;;; results via /echo; use $(/pop) and $(/dequeue) to capture their results.
/~loaded stack_queue.tf
/require lisp.tf
;;; /push <word> [<stack>]
; push word onto stack.
/def -i push = /eval /set %{2-stack}=%1 %%{%{2-stack}}
;;; /pop [<stack>]
; get and remove top word from stack.
/def -i pop = /eval /car %%{%{1-stack}}%%; /set %{1-stack}=$$(/cdr %%{%{1-stack}})
;;; /enqueue <word> [<queue>]
; put word on queue.
/def -i enqueue = /eval /set %{2-queue}=%%{%{2-queue}} %1
;;; /dequeue [<queue>]
; get and remove first word from queue.
/def -i dequeue = /pop %1-queue